home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / progtool / c / gcc / crssrc16.zoo / src / initscr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-02  |  2.1 KB  |  83 lines

  1. /*
  2.  * Copyright (c) 1981 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that the above copyright notice and this paragraph are
  7.  * duplicated in all such forms and that any documentation,
  8.  * advertising materials, and other materials related to such
  9.  * distribution and use acknowledge that the software was developed
  10.  * by the University of California, Berkeley.  The name of the
  11.  * University may not be used to endorse or promote products derived
  12.  * from this software without specific prior written permission.
  13.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  14.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  15.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  16.  */
  17.  
  18. #ifndef lint
  19. static char sccsid[] = "@(#)initscr.c    5.3 (Berkeley) 6/30/88";
  20. #endif /* not lint */
  21.  
  22. # include    "curses.ext"
  23. # include    <signal.h>
  24. # include    <unistd.h>
  25.  
  26. __EXTERN char    *getenv __PROTO((const char *));
  27.  
  28. /*
  29.  *    This routine initializes the current and standard screen.
  30.  *
  31.  */
  32. WINDOW *
  33. initscr() {
  34.  
  35.     reg char    *sp;
  36.     void        tstp __PROTO((void));
  37.     int         nfd;
  38.  
  39. # ifdef DEBUG
  40.     fprintf(outf, "INITSCR()\n");
  41. # endif
  42.     if (My_term)
  43.         setterm(Def_term);
  44.     else {
  45.         for (_tty_ch = 0; _tty_ch < nfd; _tty_ch++)
  46.             if (isatty(_tty_ch))
  47.                 break;
  48.         gettmode();
  49.         if ((sp = getenv("TERM")) == NULL)
  50.             sp = Def_term;
  51.         setterm(sp);
  52. # ifdef DEBUG
  53.         fprintf(outf, "INITSCR: term = %s\n", sp);
  54. # endif
  55.     }
  56.     _puts(TI);
  57.     _puts(VS);
  58. # if defined(SIGTSTP) && defined(__MINT__)
  59.     signal(SIGTSTP, (__Sigfunc) tstp);
  60. # endif
  61.     if (curscr != NULL) {
  62. # ifdef DEBUG
  63.         fprintf(outf, "INITSCR: curscr = 0%o\n", curscr);
  64. # endif
  65.         delwin(curscr);
  66.     }
  67. # ifdef DEBUG
  68.     fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS);
  69. # endif
  70.     if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR)
  71.         return ERR;
  72.     clearok(curscr, TRUE);
  73.     curscr->_flags &= ~_FULLLINE;
  74.     if (stdscr != NULL) {
  75. # ifdef DEBUG
  76.         fprintf(outf, "INITSCR: stdscr = 0%o\n", stdscr);
  77. # endif
  78.         delwin(stdscr);
  79.     }
  80.     stdscr = newwin(LINES, COLS, 0, 0);
  81.     return stdscr;
  82. }
  83.